package com.hksj.ecm.controller;

import com.hksj.common.core.model.Rest;
import com.hksj.ecm.entity.EnergyRate;
import com.hksj.ecm.service.EnergyRateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zengke
 * @version 1.0
 * @see EnergyRateController
 * @since 2024/8/8 16:23
 */

@Api(tags = "能耗监测-能耗费率")
@RestController
@RequestMapping("/api/energyRate")
public class EnergyRateController {

    @Autowired
    private EnergyRateService energyRateService;

    @ApiOperation(value = "新增能耗费率")
    @PostMapping("/createEnergyRate")
    public Rest<String> createEnergyRate(@RequestBody @Validated EnergyRate energyRate){
        String result = energyRateService.createEnergyRate(energyRate);
        return Rest.ok(result);
    }

    @ApiOperation(value = "修改能耗费率")
    @PostMapping("/updateEnergyRate")
    public Rest<String> updateEnergyRate(@RequestBody @Validated EnergyRate energyRate){
        String result = energyRateService.updateEnergyRate(energyRate);
        return Rest.ok(result);
    }

    @ApiOperation(value = "删除能耗费率")
    @PostMapping("/deleteEnergyRate")
    public Rest<String> deleteEnergyRate(String id){
        String result = energyRateService.deleteEnergyRate(id);
        return Rest.ok(result);
    }

    @ApiOperation(value = "根据能耗类型查询能耗费率列表")
    @PostMapping("/queryEnergyRateList")
    public Rest<List<EnergyRate>> queryEnergyRateList(String energyTypeCode){
        List<EnergyRate> energyRateList = energyRateService.queryEnergyRateList(energyTypeCode);
        return Rest.ok(energyRateList);
    }
}
